package com.ggh.jinjilive.ui.mine.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.ggh.jinjilive.R;
import com.ggh.jinjilive.databinding.ItemMineDealDetailBinding;
import com.ggh.jinjilive.databinding.ItemMineLevelBinding;
import com.ggh.jinjilive.listener.AddItemOnClickListener;
import com.ggh.jinjilive.mobile.mine.LevelMobile;
import com.ggh.jinjilive.mobile.mine.TradingDetailMobile;
import com.ggh.jinjilive.remotedata.BaseApiModule;

import java.util.List;

public class MineLevelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private List<LevelMobile> levelMobileList;

    public void setAdd(List<LevelMobile> levelMobileList) {
        this.levelMobileList = levelMobileList;
        notifyDataSetChanged();
    }


    private AddItemOnClickListener addItemOnClickListener;
    public void setAddItemOnClickListener(AddItemOnClickListener addItemOnClickListener) {
        this.addItemOnClickListener = addItemOnClickListener;
    }

    @NonNull
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ItemMineLevelBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_mine_level, parent, false);
        return new ItemViewHolder(binding);
    }

    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder recyclerViewholder,final int position) {
        LevelMobile levelMobile = levelMobileList.get(position);
        ItemViewHolder holder = (ItemViewHolder) recyclerViewholder;
        if(null != levelMobile){
            //等级
            holder.binding.tv1ExplainItem.setText(levelMobile.getLevel_name());
            //经验
            holder.binding.tv2ExplainItem.setText(levelMobile.getStart_value() +"");
            //图标
            Glide.with(holder.binding.xxExplainItem).load(BaseApiModule.host + levelMobile.getImages()).into(holder.binding.xxExplainItem);
        }
    }

    @Override
    public int getItemCount() {
        return null == levelMobileList ? 0 : levelMobileList.size();
    }


    class ItemViewHolder extends RecyclerView.ViewHolder {
        ItemMineLevelBinding binding;
        public ItemViewHolder(@NonNull ItemMineLevelBinding binding) {
            super(binding.getRoot());
            this.binding = binding;

        }
    }

}